<html>
<head>
<style type="text/css">
.chosen-container-active{
    z-index:9999 !important;;
}
.chosen-container{
	z-index:9999 !important;   
}
.ui-dialog.add-edit-form_inner-class {
  position: fixed;
}
</style>
<script type="text/javascript" src="js/ui.dropdownchecklist.js"></script>
<script type="text/javascript">
	var aJaxURL			= "server-side/operations/routes.action.php";                         //server side folder url
	var urlname			= "" ;     			              //server side file name
	var tName			= "example";												//table name
	var fName			= "add-edit-form";
	var tbName			= "tabs";											//form name
	var wsdlURL			= "server-side/wsdl/wsdl.action.php";				//server side folder url
	var tab = 0;
	var rout            =[true, true, true, true, true, true, true ];
	var districts       = [];  
	$(document).ready(function () {
		gsUnity.GetTabs(tbName);		
		$( "#check1" ).button().click(function( event ) {
			if(rout[0]){rout[0]=false}else{rout[0]=true}			
			LoadTable();
	      });
		$( "#check2" ).button().click(function( event ) {
			if(rout[1]){rout[1]=false}else{rout[1]=true}
			LoadTable();
	      });
		$( "#check3" ).button().click(function( event ) {
			if(rout[2]){rout[2]=false}else{rout[2]=true}			
			LoadTable();
	      });
		$( "#check4" ).button().click(function( event ) {
			if(rout[3]){rout[3]=false}else{rout[3]=true}
			LoadTable();
	      });
		$( "#check5" ).button().click(function( event ) {
			if(rout[4]){rout[4]=false}else{rout[4]=true}			
			LoadTable();
	      });
		$( "#check6" ).button().click(function( event ) {
			if(rout[5]){rout[5]=false}else{rout[5]=true}
			LoadTable();
	      });
		$( "#check7" ).button().click(function( event ) {
			if(rout[6]){rout[6]=false}else{rout[6]=true}
			LoadTable();
	      });
		$("#dropdown").dropdownchecklist({ firstItemChecksAll: true, explicitClose: 'დახურვა',icon: {}, width: 500, onComplete : 	LoadTable});     
		LoadTable();
	});
    function send_rs(status,letter_id) {
        var check = false;
        if      (status=='a') d="act=send_aletter&id=" + letter_id;
        else if (status=='d') d="act=send_dletter&id=" + letter_id;
        else if (status=='b') d="act=send_bletter&id=" + letter_id;
        else if (status=='e') d="act=send_eletter&id=" + letter_id;
        $.ajax({
            url: wsdlURL,
            async: false, //r-value
            data: d,
            success: function(data) {
                if (typeof(data.error) != "undefined") {
                    if (data.error != "") {
                        alert(data.error);
                    } else {
                    	alert("ზედნადები წარმატებით გაიგზავნა rs.ge-ზე!!!");

                    }
                }
                LoadTable();
            }
        });
        return check;
    }

    function signatue_dialog(later,rs_id){
        $.ajax({
            url: aJaxURL,
            async: false, //r-value
            data: "act=signature&id=" + rs_id,
            success: function(data) {
                if (typeof(data.error) != "undefined") {
                    if (data.error != "") {
                        alert(data.error);
                    } else {
                    	$("#signature").html(data.page);
                    }
                }
                LoadTable();
            }
        });
        var button = {
                "save": {
                    text: "შენახვა",
                    id: "save-dialogbn",
                    click: function () {
                        $.ajax({
                            url: aJaxURL,                          
                            data: "act=signature_save&id=" + rs_id+ "&signature_person="+$("#signature_person").val()        
                        }); 
                        $.ajax({
                            url: wsdlURL,
                            async: false, //r-value
                            data: "act=finish_overhead&rs_id=" + rs_id,
                            success: function(data) {
                                if (typeof(data.error) != "undefined") {
                                    if (data.error != "") {
                                        alert(data.error);
                                    } else {
                                    	alert("ზედნადები წარმატებით დასრულდა  rs.ge-ზე!!!");
                                   	   $(this).dialog("close");

                                    }
                                }
                                LoadTable();
                            }
                        });  
                    }
                },
                "cancel": {
                    text: "დახურვა",
                    id: "cancel-dialog",
                    click: function () {
                        $(this).dialog("close");
                    }
                }
            };
    	GetDialog("signature","auto", "auto", button);
        }

    
    function FinishOverheadRS(later,rs_id) {
   if(later=='e' || later=='b'){
	   signatue_dialog(later,rs_id);
	   }
   else{
       $.ajax({
           url: wsdlURL,
           async: false, //r-value
           data: "act=finish_overhead&rs_id=" + rs_id,
           success: function(data) {
               if (typeof(data.error) != "undefined") {
                   if (data.error != "") {
                       alert(data.error);
                   } else {
                   	alert("ზედნადები წარმატებით დასრულდა  rs.ge-ზე!!!");

                   }
               }
               LoadTable();
           }
       });
	   }            	        
        var check = false;        
        return check;
    }
	 function LoadTable() {
		 tab = GetSelectedTab(tbName);
		 districts=$("#dropdown").val();
		 var r=8;
		 if(tab==1) r = 10;
		 GetDataTable(tName+"-"+tab, aJaxURL+urlname, "get_list&tab="+tab+"&rout="+rout+"&districts="+districts, r , "", 0, "", 1, "asc", "");
		 SetPrivateEvents("add_responsible_person","check-all",fName,tName+"-"+tab);
		 SetPrivateEvents("add_responsible_person-1","check-all",fName,tName+"-"+tab);
		 GetButtons("add_responsible_person-1","");
		 GetButtons("add_responsible_person","");

     }
	function LoadDialog(){
		var buttons = {
		        "save": {
		            text: "შენახვა",
		            id: "save-printer",
		            click: function () {
		            	Change_person();
		            	LoadTable(0);
		            }
		        },
				"cancel": {
		            text: "დახურვა",
		            id: "cancel-dialog",
		            click: function () {
		                $(this).dialog("close");
		            }
		        }
		};
		GetDialog(fName, 500, "auto", buttons);
		//$("#responsible_person, #car_id").chosen();
	}

	function SetPrivateEvents(add,check,formName,tName){
		    // Add Event
		$(document).on("click", "#" + add, function () {
	        $.ajax({
	            url: aJaxURL+urlname,
	            type: "POST",
	            data: "act=get_edit_page",
	            dataType: "json",
	            success: function (data) {
	                if (typeof (data.error) != "undefined") {
	                    if (data.error != "") {
	                        alert(data.error);
	                    }else{
	                        $("#" + formName).html(data.page);
	                        if ($.isFunction(window.LoadDialog)){
	                            //execute it
	                            LoadDialog();
	                        }
	                    }
	                }
	            }
	        });
	    });
	    $("#check-all").on("click", function () {

	    	$("#" + tName + " INPUT[type='checkbox']").prop("checked", $("#" + check).is(":checked"));
	    });
	}

	function Change_person(formName){
	    var data = $(".check:checked").map(function () { //Get Checked checkbox array
	        return this.value;
	    }).get();

	    var letters = [];

	    for (var i = 0; i < data.length; i++) {
	    	letters.push(data[i]);
	    }
    	param = new Object();
    	param.act		= "change_responsible_person";
    	param.lt		= letters;
	    param.rp		= $("#responsible_person").val();
	    param.ci		= $("#car_id").val();
	    param.tab       = tab;

	    var link	=  GetAjaxData(param);

	    if(param.rp == "0"){
		    alert("აირჩიეთ პასუხისმგებელი პირი!");
		}else if(param.ci == "0"){
		    alert("აირჩიეთ ავტომობილი");
		}else{
	        $.ajax({
	        	url: aJaxURL+urlname,
	            type: "POST",
	            data: link,
	            dataType: "json",
	            success: function (data) {
	                if (typeof (data.error) != "undefined") {
	                    if (data.error != "") {
	                        alert(data.error);
	                    }else{
	                        $("#add-edit-form").dialog("close");
	                    }
	                }
	            }
	        });
		}
	}

</script>
<style type="text/css">
.btn1 {
  background-image: linear-gradient(to bottom, #ff8c8c, #b00000);
  border:none;
  border-radius: 4px;
  color: #ffffff;
  padding: 5px;
  text-decoration: none;
  width: 100%;
}

.btn1:hover {
	cursor : pointer;
	background-image: linear-gradient(to bottom, #96ffff, #0b8ba1);
}
.btn {
  background-image: linear-gradient(to bottom, #8ad2ff, #006db0);
  border:none;
  border-radius: 4px;
  color: #ffffff;
  padding: 5px;
  text-decoration: none;
  width: 100%;
}
.btn:hover {
	cursor : pointer;
	background-image: linear-gradient(to bottom, #96ffff, #0b8ba1);
}
table.display td, table.display th {
    white-space: normal;
	vertical-align: middle;
}


 #check1+label {
  background-image: linear-gradient(to bottom, #ff8c8c, #b00000);
  border:none;	
  color: #fff;  	
} 

 #check2+label {
  background-image: linear-gradient(to bottom, #8ad2ff, #006db0);
  border:none;	
  color: #fff;  	
}
 #check3+label {
  background-image: linear-gradient(to bottom, #8ad2aa, #006daa);
  border:none;	
  color: #fff;  	
}
 #check4+label {
  background-image: linear-gradient(to bottom, #8ad2ff, #006db0);
  border:none;	
  color: #fff;  	
}
 #check5+label {
  background-image: linear-gradient(to bottom, #8ad2ff, #00aab0);
  border:none;	
  color: #fff;  	
}
 #check6+label {
  background-image: linear-gradient(to bottom, #8aaaff, #006db0);
  border:none;	
  color: #fff;  	
}

.ui-button.ui-state-active .ui-button-text {
  background-color: #B2AFAF;
  color: #fff;  	
}

/* .ui-button.ui-state-hover .ui-button-text {
  background-image: linear-gradient(to bottom, #96ffff, #0b8bff);
  color: #fff;  	
} */

​
</style>
</head>

<body>
<div id="tabs" style="width: 1140px; margin: 0 auto; min-height: 768px;">
		<ul>
			<li><a href="#tab-0">დასაგეგმი მარშუტები</a></li>		
			<li><a href="#tab-1">დაგეგმილი მარშუტები</a></li>
			<li><a href="#tab-2">არქივი</a></li>
		</ul>

		
 <div id="tab-0">
    <div id="dt_example" class="ex_highlight_row">
        <div id="container">
            <div id="dynamic">
                <h2 align="center">მარშუტები</h2>
                 <select id="dropdown" multiple="multiple">
        	            <option value="0" selected="selected">(ყველა)</option>
        	            <option value="1">ვაჟა-ფშაველას კვ-ები</option>
        	            <option value="2">საბურთალო</option>
        	            <option value="3">ვაკე</option>
        	            <option value="4">ბაგები/ წყნეთი</option>
        	            <option value="5">მთაწმინდა/ სოლოლაკი</option>
        	            <option value="6">პლეხანოვი</option>
        	            <option value="7">ავლაბარი/ ისანი</option>
        	            <option value="8">ნაძალადევი</option>
        	            <option value="9">ორთაჭალა</option>
        	            <option value="10">დიდუბე</option>        	            
        	            <option value="11">დიღომი</option>
        	            <option value="12">გლდანი</option>
        	            <option value="13">ქვემო სამგორი</option>
        	            <option value="14">ვარკეთილი</option>
        	            <option value="15">ზაჰესი/ ავჭალა</option>
        	            <option value="16">აეროპორტი</option>
        	            <option value=" FALSE) or ISNULL(districts.id">რეგიონები</option>
        	           
        	        </select>
        	        <br>
        	        <br>       	       
                
	        	<div id="button_area">
	        		<button id="add_responsible_person">პ. პირის აქტივაცია</button>
	        		 <input type="checkbox" id="check1"><label for="check1">მოსატანი</label>
                     <input type="checkbox" id="check2"><label for="check2">წასაღები</label>
                     <input type="checkbox" id="check3"><label for="check3">პრინტერები</label>
                     <input type="checkbox" id="check4"><label for="check4">კარტრიჯები</label>
                     <input type="checkbox" id="check5"><label for="check5">რეგიონები</label>
                     <input type="checkbox" id="check6"><label for="check6">თბილისი</label>

	        	</div>
                <table class="display" id="example-0">
                    <thead>
                        <tr id="datatable_header">
                            <th>ID</th>
                            <th class="min" title="მიტანის დრო">მისვლის  დრო</th>
                            <th style="width: 90px;">ბარათი</th>
                            <th style="width: 60px;">რ.ობა</th>
                            <th style="width: 100%">ორგანიზაცია</th>
                            <th style="width: 110px;">ქალაქი</th>
                            <th class="min">მისამართი</th>
                            <th class="min">უბანი</th>
                            <th class="check">#</th>
                        </tr>
                    </thead>
                    <thead>
                        <tr class="search_header">
                            <th class="colum_hidden">
                            	<input type="text" name="search_id" value="ფილტრი" class="search_init" />
                            </th>
                      		<th>
                            	<input type="text" name="search_ენდdate" value="ფილტრი" class="search_init" />
                            </th>
                            <th>
                            	<input type="text" name="search_ენდdate" value="ფილტრი" class="search_init" />
                            </th>
                            <th>
                                <input type="text" id="search_letter" name="search_letter" value="ფილტრი" class="search_init" />
                            </th>
                            <th>
                                <input type="text" name="search_client" value="ფილტრი" class="search_init" />
                            </th>
                            <th>
                                <input type="text" id="search_citi"  name="search_citi" value="ფილტრი" class="search_init" />
                            </th>
                            <th>
                                <input type="text" name="search_address" value="ფილტრი" class="search_init" />
                            </th>
                            <th>
                                <input type="text" name="search_distrinct" value="ფილტრი" class="search_init" />
                            </th>
                            <th>
                            	<input type="checkbox" name="check-all" id="check-all">
                            </th>
                        </tr>
                    </thead>
                </table>
            </div>
            <div class="spacer">
            </div>
        </div>
    </div>
 </div>
 <div id="tab-1">
    <div id="dt_example" class="ex_highlight_row">
        <div id="container"  style="width: 1100px">
            <div id="dynamic">
                <h2 align="center">მარშუტები</h2>
	        	<div id="button_area">

	        	</div>
                <table class="display" id="example-1" style="white-space: normal;">
                    <thead>
                        <tr id="datatable_header">
                            <th>ID</th>
                            <th style="width: 142px" title="მიტანის დრო">მისვლის დრო</th>
                            <th style="width: 70px;">ბარათი</th>
                             <th style="width: 30px;">რ.ობა</th>
                            <th style="width: 130px">ორგანიზაცია</th>
                            <th style="width: 100px;">ქალაქი</th>
                            <th class="min">მისამართი</th>
                            <th class="min">უბანი</th>
                        	<th class="min">პ. პირი</th>
                        	<th class="min">რ/ს.ჯი</th>

                        </tr>
                    </thead>
                    <thead>
                        <tr class="search_header">
                            <th class="colum_hidden">
                            	<input type="text" name="search_id" value="ფილტრი" class="search_init" />
                            </th>
                            <th>
                            	<input type="text" name="search_ენდdate" value="ფილტრი" class="search_init" />
                            </th>
                      		<th>
                            	<input type="text" name="search_ენდdate" value="ფილტრი" class="search_init" />
                            </th>
                             <th>
                            	<input type="text" name="search_ენდdate" value="ფილტრი" class="search_init" />
                            </th>
                            <th>
                                <input type="text" id="search_letter" name="search_letter" value="ფილტრი" class="search_init" />
                            </th>
                            <th>
                                <input type="text" name="search_client" value="ფილტრი" class="search_init" />
                            </th>
                            <th>
                                <input type="text" id="search_citi"  name="search_citi" value="ფილტრი" class="search_init" />
                            </th>
                            <th>
                                <input type="text" name="search_address" value="ფილტრი" class="search_init" />
                            </th>
                            <th>
                                <input type="text" name="search_distrinct" value="ფილტრი" class="search_init" />
                            </th>
                            <th>
                                 <input type="text" name="search_distrinct" value="ფილტრი" class="search_init" />
                            </th>
                        </tr>
                    </thead>
                </table>
            </div>
            <div class="spacer">
            </div>
        </div>
    </div>
 </div>
 <div id="tab-2">
    <div id="dt_example" class="ex_highlight_row">
        <div id="container">
            <div id="dynamic">
                <h2 align="center">არქივი</h2>
	        	<div id="button_area">

	        	</div>
                <table class="display" id="example-2">
                    <thead>
                        <tr id="datatable_header">
                            <th>ID</th>
                            <th class="min" title="ტრანსპორტირების დაწყების დრო">ტრ. დაწყების დრო</th>
                            <th class="min" title="მიტანის გეგმიური დრო">მიტანის გეგ. დრო</th>
                            <th class="min" title="მიტანის ფაქტიური  დრო">მიტანის ფაქტ. დრო</th>
                            <th class="min">სხვაობა</th>
                            <th style="width: 90px;">ბარათი</th>
                            <th style="width: 100%">ორგანიზაცია</th>
                            <th style="width: 110px;">პ. პირი</th>
                         </tr>
                    </thead>
                    <thead>
                        <tr class="search_header">
                            <th class="colum_hidden">
                            	<input type="text" name="search_id" value="ფილტრი" class="search_init" />
                            </th>
                      		<th>
                            	<input type="text" name="search_ენდdate" value="ფილტრი" class="search_init" />
                            </th>
                            <th>
                                <input type="text" id="search_letter" name="search_letter" value="ფილტრი" class="search_init" />
                            </th>
                            <th>
                                <input type="text" name="search_client" value="ფილტრი" class="search_init" />
                            </th>
                            <th>
                                <input type="text" id="search_citi"  name="search_citi" value="ფილტრი" class="search_init" />
                            </th>
                            <th>
                                <input type="text" name="search_address" value="ფილტრი" class="search_init" />
                            </th>
                            <th>
                                <input type="text" name="search_distrinct" value="ფილტრი" class="search_init" />
                            </th>
                            <th>
                            </th>
                        </tr>
                    </thead>
                </table>
            </div>
            <div class="spacer">
            </div>
        </div>
    </div>
 </div>

    <div id="add-edit-form"  class="form-dialog" title="პასუხისმგებელი პირი">
    	<!-- aJax -->
	</div>
	<div id="signature" class="form-dialog" title="შემოიტანეთ ხელმომწერი">
    	<!-- aJax -->
	</div>
	
</div>

</body>
</html>